package com.mode.prototype.pattern;

import java.util.Arrays;

/**
 * @Description: 原型模式：用原型实例指定创建对象的种类，并且通过拷贝这些原型创建新的对象
 * 构造函数是不会执行
 * @Author: zyf
 * @Time: 2020/9/27 15:25
 */
public class PrototypeMain {

    public static void main(String[] args) {
        InstanceDO instanceDO1,instanceDO2;

        instanceDO1 = new InstanceDO();
        instanceDO1.setName("小明");
        instanceDO1.setFriends(Arrays.asList("1","2","3"));
        instanceDO2 = instanceDO1.clone();
        System.out.printf("neirogn:"+instanceDO2.getFriends());
        instanceDO2.setFriends(Arrays.asList("one","two"));
        // instanceDO1 并未发生改变
        System.out.printf("实例1"+instanceDO1.getFriends());
    }
}
